<template>
    <uni-list v-if="shareAppointment.length > 0">
        <uni-list-item v-for="(item, index) in shareAppointment" :key="index" :rightText="item.gaStat ? '已购买' : '未购买'">
            <template v-slot:body style="width: 250px">
                <view style="font-size: 16px; font-weight: 600">{{ (item.cust?.ciName || "") + (item.cust?.ciAlia ? "(" + item.cust?.ciAlia + ")" : "") + item.cust?.ciPhon }}</view>
                <view style="font-size: 12px; color: dimgrey">{{ "预约项目：" + (item.item?.giName || "") }}</view>
                <view style="font-size: 12px; color: dimgrey">{{ item.staff?.orName ? "所属员工：" + item.staff?.orName : "" }}</view>
            </template>
        </uni-list-item>
    </uni-list>
</template>

<script>
    import { getAppointmentByGaCuid } from "../../utils/api";
    import { mapGetters } from "vuex";

    export default {
        data() {
            return {
                shareAppointment: []
            }
        },
        computed: {
            ...mapGetters({
                activity: "activityInfo/activity",
            }),
        },
        onLoad(params) {
            if (params.ciUuid) {
                this.loadAppointmentByGaCuid({gpUuid: this.activity.gpUuid, gaCuid: params.ciUuid})
            }
        },
        methods: {
            async loadAppointmentByGaCuid({gpUuid, gaCuid}) {
                let res = await getAppointmentByGaCuid({
                    gpUuid,
                    gaCuid
                })
                if (res) this.shareAppointment = res
            }
        }
    }
</script>

<style>
</style>